//
//  RegisterViewController.m
//  BaoGongBao
//
//  Created by User on 14/11/16.
//  Copyright (c) 2014年 irule. All rights reserved.
//

#import "RegisterViewController.h"

@interface RegisterViewController ()

@end

@implementation RegisterViewController

- (void)leftBarButtonItemSelector:(id)sender
{
	exit(0);
//	[self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)rightBarButtonItemSelector:(id)sender
{
	[self.mTFMobile resignFirstResponder];
	if ([self.mTFMobile.text isEqualToString:@""]) {

		[[iToast makeText:kNRStr_register_mobileisnull] show];
		return;
	}

	//-->param:{PlatForm=3, mobilenum=15256995851, appid=HMP_001, DeviceName=MI 2S, OSName=android 4.1.1, loginplace=中国,安徽省,合肥市,蜀山区,创业大道,117.201456,31.861073, deviceid=860955020541003}
    NSLog(@"%@",gloginplace);
    if(gloginplace == nil)
    {
        gloginplace = @"";
    }
        
	NSDictionary *dictionary = @{@"mobilenum"	: self.mTFMobile.text,
								 @"PlatForm"	: kSys_PlatForm,
								 @"appid"		: kSys_appid,
								 @"DeviceName"	: [UIDevice currentDevice].model,
								 @"OSName"		: [NSString stringWithFormat:@"%@ %@", [UIDevice currentDevice].systemName, [UIDevice currentDevice].systemVersion],
								 @"loginplace"	: _myLocations,
								 @"deviceid"	: kSys_deviceid//[OpenUDID value]
								 };
	[[NetWorkRequestApi sharedNetWorkRequestApi] nrRegister:dictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {

		switch ([[responseObject objectForKey:@"Tag"] integerValue]) {
		  case 1:
			{
				[[iToast makeText:[responseObject objectForKey:@"Message"]] show];
				CaptchaViewController *vc = [[CaptchaViewController alloc] initWithNibName:nil bundle:nil];
                vc.myLocations = _myLocations;
				vc.strMobile = self.mTFMobile.text;
				[self.navigationController pushViewController:vc animated:YES];
			}
				break;
			case 0:
			{
                UIAlertView *alt = [[UIAlertView alloc]initWithTitle:nil message:[responseObject objectForKey:@"Message"] delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
                [alt show];
			}
		  default:
				break;
		}
	} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

		[[iToast makeText:kNRStr_LoadDataFailure] show];
	}];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//	self.title = @"账户注册";

	UILabel *lbTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 80)];
	lbTitle.textColor = [UIColor whiteColor];
	lbTitle.textAlignment = NSTextAlignmentCenter;
	lbTitle.text = @"账户注册";
	self.navigationItem.titleView = lbTitle;
	self.mTFMobile.keyboardType = UIKeyboardTypePhonePad;
	self.mTFMobile.layer.cornerRadius = 5;
	self.mTFMobile.layer.borderWidth = 1;
	self.mTFMobile.layer.borderColor = [UIColor lightGrayColor].CGColor;
	//[self.view addSubview:self.mTFMobile];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
